/**
 *
 */
package com.storm.lib.task;

import com.storm.lib.base.BaseTask;
import com.storm.lib.template.MemoryTemplate;
import com.storm.lib.type.DateType;
import com.storm.lib.type.SystemType;
import com.storm.lib.util.BeanUtil;
import com.storm.lib.util.DateUtil;

/**
 * 类功能: 定时器任务
 * @author johnny
 * @version 2010-11-25
 */
public class SyncDBTask extends BaseTask {

	public static MemoryTemplate memoryTemplate;

	@Override
	public void run() {
		setRunState(SystemType.THREAD_STATE_RUN);
		memoryTemplate.flushDatasToDB();
		setRunState(SystemType.THREAD_STATE_WAIT);
	}

	public SyncDBTask() {
		this.setFirstDelayMS(DateUtil.getMSCount(DateType.TIME_TYPE_MS, 10*1000));
		this.setRepeatDelayMS(DateUtil.getMSCount(DateType.TIME_TYPE_MS, 10*1000));
		if(memoryTemplate==null){
			memoryTemplate = (MemoryTemplate) BeanUtil.getBean("memoryTemplate");
		}

	}

}
